package com.cidp.system.service.impl;

import java.util.Date;
import java.util.List;

import com.cidp.system.dao.IOpLogDao;
import com.cidp.system.model.TopLog;
import com.cidp.system.service.IOpLogService;
import com.litt.core.exception.BusiException;
import com.litt.core.page.IPageList;
import com.litt.core.page.PagePoParam;

/**
 * <b>标题：</b>日志查询Service实现.
 * 
 * <pre>
 * &lt;b&gt;描述&lt;/b&gt;
 *    日志查询
 * </pre>
 * 
 * @author lijian
 * @since 2008-5-23
 * @version 1.0
 */
public class OpLogServiceImpl implements IOpLogService {
	
	private IOpLogDao opLogDao;

	/**
	 * 读取日志信息
	 * 
	 * @param topId 日志ID
	 * @return TopLog对象
	 * @throws BusiException
	 */
	public TopLog loadById(Long topId) throws BusiException{
		if(topId != null)
			return opLogDao.loadById(topId);
		else
			throw new BusiException("传入参数为空");
	}

	/**
	 * 删除日志信息.
	 * 
	 * @param topLog 日志对象
	 * @throws BusiException
	 */
	public void deleteTopLog(TopLog topLog) throws BusiException{
		if(topLog != null)
			 opLogDao.deleteObject(topLog);
		else
			throw new BusiException("传入参数为空");
	}
	
	/**
	 * 删除日志信息.
	 * 
	 * @param id 日志对象Id
	 * @throws BusiException
	 */
	public void deleteTopLogById(Long id) throws BusiException{
		if(id != null){
			TopLog opLog = opLogDao.loadById(id);
			opLogDao.deleteObject(opLog);
		} 
		else
			throw new BusiException("传入参数为空");
	}

	/**
	 * 保存日志信息.
	 * 
	 * @param topLog 日志对象
	 * @return 主键
	 * @throws BusiException
	 */
	public Long saveTopLog(TopLog opLog) throws BusiException{
		if(opLog != null)
			return opLogDao.saveTopLog(opLog);
		else
			throw new BusiException("传入参数为空");
	}

	/**
	 * 更新日志信息.
	 * 
	 * @param topLog 日志对象
	 * @throws BusiException
	 */
	public void updateTopLog(TopLog topLog) throws BusiException{
		if(topLog != null)
			 opLogDao.updateTopLog(topLog);
		else
			throw new BusiException("传入参数为空");
	}
	
	/**
	 * 根据操作时间和操作员Id查询对象
	 * 
	 * @param startDate 开始时间
	 * @param endDate	结束时间
	 * @param opId		操作员Id
	 * 
	 * @return TopLog对象列表
	 * @throws BusiException
	 */
	public List listByOpDatetimeAndOpId(Date startDate,Date endDate,Long opId) throws BusiException{
		if(startDate == null)
			throw new BusiException("开始时间为空");
		if(endDate == null)
			throw new BusiException("开始时间为空");
		if(opId == null)
			throw new BusiException("操作员Id为空");
		
		return opLogDao.listByOpDatetimeAndOpId(startDate, endDate, opId);
	}
	
	/**
	 * 分页查询操作日志信息.
	 * 
	 * @param pagePoParam 查询参数
	 * @return IPageList IPageList对象
	 * @throws BusiException
	 */
	public IPageList listByPage(PagePoParam pagePoParam) throws BusiException{
		if(pagePoParam != null)
			 return opLogDao.listByPage(pagePoParam);
		else
			throw new BusiException("传入参数为空");
	}

	public void setopLogDao(IOpLogDao opLogDao) {
		this.opLogDao = opLogDao;
	}

	public void setOpLogDao(IOpLogDao opLogDao) {
		this.opLogDao = opLogDao;
	}
	
}

